package service;

import java.util.List;

import util.Pager;
import dao.CommentDao;
import dao.IdeaDao;
import entity.Comment;
import entity.Idea;

public class IdeaService {
    
    private IdeaDao idd = new IdeaDao();
    private CommentDao cd = new CommentDao();
    
    public Pager<Idea> findAll(int projectId, int pageNum) {
        return idd.findAll(projectId, pageNum);
    }
    
    public int addIdea(Idea idea) {
        return idd.addIdea(idea);
    }

	public void delIdea(int id) {
		cd.delCommentByIdeaId(id);
		idd.delIdea(id);
	}

	public Idea findById(int id) {
		return idd.findByIdeaId(id);
	}

	public void updateIdea(Idea idea) {
		idd.updateIdea(idea);
		
	}

    public List<Comment> findByIdeaId(int id) {
        return cd.findByIdeaId(id);
    }
    
    public int addComment(Comment comment) {
        return cd.addComment(comment);
    }
    
    public int delComment(int commentId) {
        return cd.delComment(commentId);
    }
}
